<?php
	$value = $this->element->getValue();
	$userinput = $value['userinput'];
	$value = $value['value'];
?>

<h2><?= $this->escape($this->element->getAttrib('title')) ?></h2>
<select id="<?= $this->element->getName() ?>" name="<?= $this->element->getName() ?>[value]">
	<option value="0">(prosze wybrac)</option>
	<?php foreach($this->element->getAttrib('options') as $weight=>$text) { ?>
	<option value="<?= (int)$weight ?>" <?= $value === (string)$weight ? 'selected="selected"' : '' ?>><?= $this->escape($text) ?></option>
	<?php } ?>

	<?php if ($this->element->getAttrib('label_other')): ?>
	<option value="other" <?= $value === 'other' ? 'selected="selected"' : '' ?>><?= $this->escape($this->element->getAttrib('label_other')) ?></option>
	<?php endif; ?>
</select>
<?php if ($this->element->getAttrib('label_other')): ?>
<div class="other">
	<label class="other" for="<?= $this->element->getName() ?>_other"><?= $this->escape($this->element->getAttrib('label_other')) ?></label>
	<input type="text" value="<?= $this->escape($userinput) ?>" id="<?= $this->element->getName() ?>_other" name="<?= $this->element->getName() ?>[userinput]" />
</div>
<?php endif; ?>
